<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录</title>
  <style>
    body {
      padding: 0;
      margin: 0;
    }
    .login-page {
      display: flex;
      align-items: center;
      justify-content: center;
      background-size: 66px 32px;
      background-color: #5e85c0;
      background-repeat: no-repeat;
      font-size: 12px;
      height: 100vh;
    }
    .login-form {
      width: 300px;
    }
    .login-title {
      padding-bottom: 20px;
      color: #fff;
      font-size: 32px;
      text-align: center;
    }
    .input {
      width: 100%;
      height: 30px;
      margin-bottom: 20px;
      border: 0;
      background: #fff;
      border-radius: 3px;
    }
    .login-btn {
      width: 100%;
      padding: 6px 0;
      color: #323232;
      background: #FBEB1A;
      border: 0;
      border-radius: 3px;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div class="login-page">
    <div class="login-form">
      <div class="login-title">管理员登录</div>
        <input id="js-username" class="input" type="text" placeholder="请输入用户名">
        <input id="js-password" class="input" type="text" placeholder="请输入密码">
        <button class="login-btn" onclick="login()">登录</button>
    </div>
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
  <script>
    function login() {
      axios.post('/login', {
        username: document.getElementById('js-username').value,
        password: document.getElementById('js-password').value
      }).then(res => {
        if (res.data.code === 0) {
          localStorage.setItem('userToken', document.getElementById('js-username').value)
          location.href = '/index.html'
        } else {
          alert(res.data.msg)
        }
      })
    }
  </script>
</body>
</html>